package me.zk.practice1.hw;

import java.util.*;

/**
 * @author zhangkai
 * @date 2023/8/7 14:52
 */
public class HWBJ76 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();

        s = s.substring(1,s.length()-1);

        int[] nums = Arrays.stream(s.split(",")).mapToInt(Integer::parseInt).toArray();


        int n = Integer.parseInt( scanner.nextLine());

        List<int[]> list = new ArrayList<>();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if (map.containsKey(num)) {
                list.add(new int[]{map.get(num), i});
                map.remove(num);
            } else {
                // 防止后面相同元素覆盖
                if (map.containsKey(n - num)) {
                    continue;
                }
                map.put(n - num, i);
            }
        }
        list.sort(Comparator.comparingInt(a -> (a[0] + a[1])));
        System.out.println(Arrays.toString(list.get(0)));
    }
}
